import threading
import time

def job(x,y,book):
    time.sleep(0.001)
    for i in range(x,y):
        book.write(str(i) + '\n')

def multithreading(book):
    threads = []
    t1 = threading.Thread(target=ope)
    t1.daemon = True
    #t1.start()
    for i in range(10):
        t = threading.Thread(target=job, args=(100 * i, (i + 1) * 100,book), name='T%i' % i)
        t.start()
        threads.append(t)
    [t.join() for t in threads]

def normal(l,bok):
    for i in l:
        bok.write(str(i) + '\n')

def ope():
    with open(r'C:\Users\Administrator\Desktop\jjjjjj.txt', 'a+') as book:
        s_t = time.time()
        multithreading(book)
        print('multithreading: ', time.time() - s_t)

if __name__ == '__main__':
    l = list(range(1,1000))
    s_t = time.time()
    with open(r'C:\Users\Administrator\Desktop\dddddd.txt', 'a+') as file:
        normal(l,file)
    print('normal: ', time.time() - s_t)
    ope()